﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aribaccio;
using CommunityToolkit.Mvvm.ComponentModel;

namespace BDPAutodetect.Models
{
    /// <summary>
    /// 权限菜单类
    /// </summary>
    public partial class MPowerMenu : ObservableModel
    {
        /// <summary>
        /// 权限许可
        /// </summary>
        public MPowerPermission PowerPermission { get; protected set; }

        /// <summary>
        /// 菜单名称
        /// </summary>
        [ObservableProperty]
        protected string name;

        /// <summary>
        /// 菜单相对链接地址
        /// </summary>
        [ObservableProperty]
        protected string? url;

        /// <summary>
        /// 图标
        /// </summary>
        [ObservableProperty]
        protected string? inco;

        /// <summary>
        /// 显示图标
        /// </summary>
        [ObservableProperty]
        protected string? incoDisplay;

        /// <summary>
        /// 是否选中
        /// </summary>
        [ObservableProperty]
        protected bool isSelected;

        /// <summary>
        /// 构造函数
        /// </summary>
        public MPowerMenu(MPowerPermission argPowerPermission, bool argIsSelected = false)
        {
            this.PowerPermission = argPowerPermission;
            this.Name = argPowerPermission.Power.Name;
            this.Url = argPowerPermission.Power.Url;
            this.Inco = argPowerPermission.Power.Inco;
            this.IsSelected = argIsSelected;
            this.SetIncoDisplay(this.Url);
        }

        /// <summary>
        /// 设置显示图标
        /// </summary>
        /// <param name="argUrl"></param>
        protected void SetIncoDisplay(string? argUrl)
        {
            switch (argUrl)
            {
                case "MainPage": this.IncoDisplay = "\xe6cb"; break;
                case "Parameter": this.IncoDisplay = "\xe697"; break;
                case "DetectTarget": this.IncoDisplay = "\xe656"; break;
                case "DetectRecord": this.IncoDisplay = "\xe810"; break;
                case "Setting": this.IncoDisplay = "\xe60e"; break;
                case "SettingSystem": this.IncoDisplay = "\xe80D"; break;
                case "SettingStation": this.IncoDisplay = "\xe794"; break;
                case "SettingTarget": this.IncoDisplay = "\xe855"; break;
                case "SettingDeviceSlave": this.IncoDisplay = "\xe869"; break;
                case "SettingDeviceChannel": this.IncoDisplay = "\xe626"; break;
                case "SettingUserRole": this.IncoDisplay = "\xe682"; break;
                case "SettingRolePower": this.IncoDisplay = "\xe666"; break;              
            }
        }
    }
}
